<?php 

	define('CLASS_PREFIX', '');

	static function &load_class($class_name, $core_dir = null)
	{
		static $classes = array();
		
		if(isset($classes[$class_name]))
		{
			return $classes[$class_name];
		}
		
		$path = BASEPATH . 'core/classes/';
		
		if($core_dir !== null)
		{
			$path = BASEPATH . 'core/' . $core_dir . '/';
		}
		
		$path .= $class_name . CLASS_PREFIX . '.php';
		
		if(file_exists($path)){
			include $path;	
		}
		
		return $classes[$class_name] = new $class_name();
	}
	
	// Example usage:
	// $db =& load_class('db');
	// $db->query('SELECT * FROM `users` WHERE `id` = ?', $user_id);
	//
	// $guest_book =& load_class('guest_book', 'core/modules');
	// $guest_book->create_comment('test');

# END